import 'package:flutter_ahj_app/app/my/invoicing/HttpConfiguration/FP_HttpRequest.dart';
import 'package:flutter_ahj_app/app/my/invoicing/ChooseFaPiaoNeiRong/bean/FP_PresetInvoice_Bean.dart';
import 'package:flutter_ahj_app/base/basewidget/model/BaseModel.dart';
import 'package:rxdart/subjects.dart';

class ChooseFaPiaoNeiRongModel extends BaseModel {
  BehaviorSubject<FPPresetInvoiceBean> _dataSubject;

  Stream<FPPresetInvoiceBean> get dataStream => _dataSubject.stream;

  getData(String supplierId) {
    _dataSubject = BehaviorSubject();

    FPHttpRequest.getSuppliertype(supplierId: supplierId).listen((event) {
      FPPresetInvoiceBean fpPresetInvoiceBean =
          FPPresetInvoiceBean.fromJson(event);

      _dataSubject.add(fpPresetInvoiceBean);
    }, onError: (e) {

      errorData.add(e);
    });
  }

  @override
  void dispose() {
    // TODO: implement dispose
    if (_dataSubject != null) {
      _dataSubject.close();
    }
    super.dispose();
  }
}
